javascript:
var obj_arr =[],obj ={};
var trainclassId = window.location.href.match(/trainclassId=(\d+)/) && window.location.href.match(/trainclassId=(\d+)/)[1];
if(trainclassId){
    setTimeout(()=>get(),100);
}
function get(){
    for(var i=0;i<$('.flex .function-desc-progress').length;i++){
        if($('.flex .function-desc-progress')[i] && $($('.flex .function-desc-progress')[i]).html()){
            var time = $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/<divclass="progres-wrapper-time">(.+?)<\/div>/) && $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/<divclass="progres-wrapper-time">(.+?)<\/div>/)[1];
            var p = $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/<divclass="line-progress-percentline-progress-percent-bx">(.+?)<\/div>/) && $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/<divclass="line-progress-percentline-progress-percent-bx">(.+?)<\/div>/)[1];
            var para = $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/(startLesson\(.+?\))/) && $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/(startLesson\(.+?\))/)[1];
            time = time.replace(/[^0-9]/g,'');
            p = p.replace(/%/,'');
            var status_text = $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/已完成|未开始|进行中/) && $($('.flex .function-desc-progress')[i]).html().replace(/\s|\n|\r/g,'').match(/已完成|未开始|进行中/)[0];
            var obj1 = {};
            para = para.replace(/startLesson/ig,'add_para');
            eval(para);
            function add_para(lessonId, coursewareId, lessonkey, tclessonId, type){
                var playtime = Math.floor(time*((100-p)/100))*60*1000;
                obj1 = {"lessonId":lessonId, "coursewareId":coursewareId, "lessonkey":lessonkey, "tclessonId":tclessonId, "type":type,"playtime":playtime,"status_text":status_text,"time":time}
            }
            //console.log(i);
            obj_arr.push(obj1);
        }
    }
    for(var t=0;t<obj_arr.length;t++){
        obj = obj_arr[t];
        //console.log(obj);
        if(obj.status_text.match(/已完成/)==null){
			console.log('找到了未完成的课'+t);
            start(obj);            
            break;
        }
    }
}

function start(obj) {
    var lessonId = obj.lessonId;
    var coursewareId = obj.coursewareId;
    var lessonkey = obj.lessonkey;
    var tclessonId = obj.tclessonId;
    var type = obj.type;
    if (type == 0 || type == 1) {
        $.ajax({
            type: "post",
            url: 'https://www.gxela.gov.cn:443/app/tms/tclesson/Tclesson/learnOrder.do',
            async: false, // 同步调用
            dataType: 'json',
            data: {'tclessonId': tclessonId, 'trainclassId':trainclassId},
            success: function (data) {

                if (data["success"] == 1) {
                    alert('请先学习' + data["lessonName"] + '后再学习该门课程');
                } else {
                    var winName = '_blank';
                    var url = "https://www.gxela.gov.cn:443/app/lms/student/Learn/enter.do?lessonId=" + lessonId + "&coursewareId=" + coursewareId + "&lessonGkey=" + lessonkey + "&tclessonId=" + tclessonId + "&lessonOrigin=trainclass";
                    //console.log(JSON.stringify(obj));
					console.log('开始看课~');
                    setTimeout(()=>kanke(obj),500);                    
                }
            },
            error: function () {

            }
        });
    } else if (type == 2) {
        $.ajax({
            type: "get",
            url: "https://www.gxela.gov.cn:443/app/zwy/api/Api/takeZwyLessonUrl.do?lessonId=" + lessonId + "&trainclassId=" + trainclassId4Ajax,
            success: function (res) {
                if (res.success) {
                    //window.open(res.url, "_blank");
                    _openFullWindowCenter(res.url, 'classroomWin', 'true', '您正在学习，请在学习结束后，点击[确认]按钮，刷新本页面', lessonId, type);
                } else {
                    //alert(res.msg);
                }
            },
            error: function () {
                alert('error');
            }
        });
    }
}
async function kanke(obj){	
    var lessonId = obj.lessonId;
    var tclessonId = obj.tclessonId;
    var coursewareId = obj. coursewareId;
    var lessonGkey = obj.lessonkey;
    var playtime = obj.playtime;
    console.log(JSON.stringify(obj));
    var _status = '';
    var t0 = await $.get("https://www.gxela.gov.cn/app/lms/student/Learn/enter.do?lessonId="+lessonId+"&coursewareId="+coursewareId+"&lessonGkey="+lessonGkey+"&tclessonId="+tclessonId+"&lessonOrigin=trainclass",function(data,status){
        _status += status;
        data = data.replace(/\r|\n|\s/g,'');
        if(data.match(/无此课程/)==null){
            console.log(getnowtime()+' 打开课程学习',data.length);
        }else{
            console.log(getnowtime()+' 打开课程学习失败',data.length);
        }
    });
    var t1 = await $.get("https://www.gxela.gov.cn/app/lms/student/Learn/exitLesson.do?lessonId="+lessonId+"&tclessonId="+tclessonId+"&lessonOrigin=trainclass&standard=3&isPreview=false&isMobile=false",function(data,status){
        _status += status;
        console.log(getnowtime()+' 打开iframe1',data.length);
    });
    var t2 = await $.get("https://www.gxela.gov.cn/app/lms/student/Learn/mp4Cloudplayer.do?lessonId="+lessonId+"&coursewareId="+coursewareId+"&tclessonId="+tclessonId+"&lessonOrigin=trainclass&isPreview=false&exitplaytime=62&userId=21329081",function(data,status){
        _status += status; 
        console.log(getnowtime()+' 打开iframe2',data.length);
    });
    var t3 = await $.get("https://www.gxela.gov.cn/app/lms/student/Learn/recordLearnTime.do?lessonId="+lessonId+"&tclessonId="+tclessonId+"&lessonOrigin=trainclass&standard=3&isPreview=false&isMobile=false",function(data,status){
        _status += status;
        console.log(getnowtime()+' 打开iframe3',data.length);
    });
    var _time = 1000*60*2;
	console.log('总时长'+obj.time+'min，已看了'+(playtime/60000)+'min，剩余'+(obj.time-playtime/60000)+'min');
    if(_status.match(/error/)==null){
        setInterval(()=>{
            playtime = playtime - _time;
            window.obj.playtime = playtime;
			console.log('总时长'+obj.time+'min，已看了'+(playtime/60000)+'min，剩余'+(obj.time-playtime/60000)+'min');
            if(playtime){
                recordLearnTime(lessonId,tclessonId,playtime);
            }else{
                exit(lessonId,tclessonId,playtime);
            }
        },_time);
    }
}
function recordLearnTime(lessonId,tclessonId,playtime){
    var url = "https://www.gxela.gov.cn/app/lms/student/Learn/recordLearnTime.do";
    $.ajax({
        cache: false,
        type: 'post',
        async: false,
        url: 'https://www.gxela.gov.cn:443/app/lms/student/Learn/recordLearnTime.do',
        data:{"lessonId":lessonId,"tclessonId":tclessonId,"lessonOrigin":"trainclass","standard":3,"isPreview":false,"isMobile":false,"exitplaytime":playtime},
        success: function(data, textStatus) {
            console.log(textStatus);
        },
        complete: function(xhr, textStatus) {
        },
        error: function(){
            //alert("提交失败");
        }
    });
}
function exit(lessonId,tclessonId,playtime){
    var url = "https://www.gxela.gov.cn:443/app/lms/student/Learn/exit.do";
    var lessonId = obj.lessonId;
    var tclessonId = obj.tclessonId;
    var coursewareId = obj. coursewareId;
    var lessonGkey = obj.lessonkey;
    var playtime = obj.playtime;
    $.ajax({
        cache: false,
        type: 'post',
        async: false,
        url: url,
        data:{"lessonId":lessonId,"tclessonId":tclessonId,"lessonOrigin":"trainclass","standard":3,"isPreview":false,"exitplaytime":playtime},
        success: function(data, textStatus) {
        },
        complete: function(xhr, textStatus) {
            setTimeout(()=>window.location.reload(),1000);
        },
        error: function(){
            setTimeout(()=>exit(lessonId,tclessonId,exitplaytime),1000);
        }
    });
}
$(window).bind('beforeunload',function(){
    var lessonId = obj.lessonId;
    var tclessonId = obj.tclessonId;
    var coursewareId = obj. coursewareId;
    var lessonGkey = obj.lessonkey;
    var playtime = obj.playtime;
    $.ajax({
        cache: false,
        type: 'post',
        async: false,
        url: 'https://www.gxela.gov.cn:443/app/lms/student/Learn/exit.do',
        data:{"lessonId":lessonId,"tclessonId":tclessonId,"lessonOrigin":"trainclass","standard":3,"isPreview":false,"exitplaytime":playtime},
        success: function(data, textStatus) {
        },
        complete: function(xhr, textStatus) {
        },
        error: function(){
            //alert("提交失败");
        }
    });

});
function getnowtime(t) { function b0(n) { if (n < 10) { n = '0' + n; } return n; } function b00(num){ if(num<10){ num = "00"+num; }else if(num<100){ num = "0"+num; } return num; } if (t != undefined) { t = new Date(t) } else { t = new Date() } var year = t.getFullYear(); var month = t.getMonth() + 1; var day = t.getDate(); var HH = t.getHours(); var MM = t.getMinutes(); var SS = t.getSeconds(); var MS = t.getMilliseconds(); var now_time = year + '-' + b0(month) + '-' + b0(day) + ' ' + b0(HH) + ':' + b0(MM) + ':' + b0(SS) + '.' + b00(MS); /*console.log(now_time);*/ return now_time; }